//加载视图
var LoadingPageView=function(){
    this.Container_constructor();
	var self=this,_w=as.properties.width,_h=as.properties.height;

    var rect=new cjs.Shape();
	rect.graphics.beginFill("#2a2a2a");
	rect.graphics.drawRect(0,0,_w,_h);
	rect.graphics.endFill();
	rect.parent=this;
	this.addChild(rect);
    //标题
    var title = new cjs.Text("BattleTank", "40px Arial", "#ffffff");
    title.setTransform((_w-title.getBounds().width)/2,40);
    title.parent=this;
    this.addChild(title);
    //版本
    var version=new cjs.Text("V1.0.0", "12px Arial", "#ffffff");
    version.setTransform(10,_h-version.getBounds().height);
    version.parent=this;
    this.addChild(version);
    //加载进度条
    var loading_bar=new LoadingBar();
    loading_bar.setTransform(200,(_h-10)/2);
	loading_bar.parent=this;
	this.addChild(loading_bar);
	loading_bar.width=_w-400;
	loading_bar.height=10;

    this.setProgress=function(value){
        //console.log(value);
        loading_bar.setProgress(value);
    };
};
p=cjs.extend(LoadingPageView,cjs.Container);
LoadingPageView = cjs.promote(LoadingPageView, "Container");
//菜单视图
var MenuView=function(){
    this.Container_constructor();
	var self=this,_w=as.properties.width,_h=as.properties.height;
    
    var menu=new cjs.Bitmap(images.menu);
    menu.setTransform((_w-menu.getBounds().width)/2,_h);
    menu.parent=this;
    this.addChild(menu);
    //菜单缓缓升起
    this.startMenuAnimate=function(){
        cjs.Tween.get(menu).to({y:0},2000).call(function(){
            select.parent=self;
            self.addChild(select);
        });
    };
    //
    var select=new SelectCursor();
    select.setTransform(menu.x+140,250);
    select.play();
    //点击事件
    self.on('click',function(){
        /*if(select.y==250){
            select.y=281;
        }else{
            select.y=250;
        }*/
        self.dispatchEvent(ViewEvent.GAME_START);
    },null,false);
};
p=cjs.extend(MenuView,cjs.Container);
MenuView = cjs.promote(MenuView, "Container");
//关卡过渡屏
var LevelView=function(){
    this.Container_constructor();
	var self=this,_w=as.properties.width,_h=as.properties.height;
    //
    var rect0=new cjs.Shape();
	rect0.graphics.beginFill("#7f7f7f");
	rect0.graphics.drawRect(0,0,_w,_h);
	rect0.graphics.endFill();
    rect0.setTransform(0,-_h);
	rect0.parent=this;
	this.addChild(rect0);
    //
    var rect1=new cjs.Shape();
	rect1.graphics.beginFill("#7f7f7f");
	rect1.graphics.drawRect(0,0,_w,_h);
	rect1.graphics.endFill();
    rect1.setTransform(0,_h);
	rect1.parent=this;
	this.addChild(rect1);
    //
    var level_label=new LevelLabel(1);
    //level_label.value=1;
    level_label.setTransform((_w-level_label.getBounds().width)/2,_h/2);
    //动画
    this.startAnimate=function(){
        //
        cjs.Tween.get(rect0).to({y:-_h/2+1},500);
        cjs.Tween.get(rect1).to({y:_h/2-1},500).call(function(){
            level_label.parent=self;
            self.addChild(level_label);
            //
            setTimeout(function(){
                self.dispatchEvent(ViewEvent.LEVEL_ANIMATE_COMPLETE,true);
            },1000);
        });
    };
};
p=cjs.extend(LevelView,cjs.Container);
LevelView = cjs.promote(LevelView, "Container");
//游戏
var GameView=function(){
    this.Container_constructor();
	var self=this,_w=as.properties.width,_h=as.properties.height;
    //
    var map=new Map();
    map.parent=self;
    self.addChild(map);
    map.mapdraw();
};
p=cjs.extend(GameView,cjs.Container);
GameView = cjs.promote(GameView, "Container");